package com.niit.mystudent;

import com.niit.entity.Course;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Processor;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.context.annotation.Bean;
import org.springframework.messaging.Message;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@MapperScan("com.niit.mystudent.dao")
@EnableDiscoveryClient
@EnableFeignClients
@EnableBinding({Processor.class})
public class MystudentApplication {

  @Bean
  @LoadBalanced
  RestTemplate getRestTemplate(){
    return new RestTemplate();
  }

  public static void main(String[] args) {
    SpringApplication.run(MystudentApplication.class, args);
  }

  @StreamListener(Sink.INPUT)
  public void receiveMessage(Message<Course> msg) {
    System.out.println("接收到的消息是: " + msg.getPayload());
  }
}
